FROM ubuntu:22.04

# 安装必要依赖
RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    git \
    llvm-dev \
    clang \
    unzip \
    && rm -rf /var/lib/apt/lists/*

# 设置环境变量
ENV CANGJIE_HOME=/opt/cangjie
ENV CANGJIE_STDX_PATH=/opt/cangjie/stdx

# 复制并解压仓颉SDK
COPY cangjie-sdk-linux-aarch64-1.0.1.tar.gz /tmp/
RUN mkdir -p ${CANGJIE_HOME} \
    && tar -xzf /tmp/cangjie-sdk-linux-aarch64-1.0.1.tar.gz --strip-components=1 -C ${CANGJIE_HOME} \
    && rm /tmp/cangjie-sdk-linux-aarch64-1.0.1.tar.gz

# 复制并解压STDX库
COPY cangjie-stdx-linux-aarch64-1.0.1.2.zip /tmp/
RUN unzip /tmp/cangjie-stdx-linux-aarch64-1.0.1.2.zip -d /tmp/ \
    && mkdir -p ${CANGJIE_STDX_PATH} \
    && cp -r /tmp/linux_aarch64_llvm ${CANGJIE_STDX_PATH}/ \
    && rm /tmp/cangjie-stdx-linux-aarch64-1.0.1.2.zip \
    && rm -rf /tmp/linux_aarch64_llvm

# 设置PATH环境变量
ENV PATH=${CANGJIE_HOME}/bin:${CANGJIE_HOME}/tools/bin:$PATH

# 验证安装
RUN ls -la ${CANGJIE_HOME} && ls -la ${CANGJIE_STDX_PATH}